<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>发布-技术社区</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <!--引入bootstrap的css样式和js-->
    <link rel="stylesheet" href="/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <!--markdown css-->
    <link rel="stylesheet" href="/css/editormd.css"/>
    <!--自定义css样式-->
    <link rel="stylesheet" href="/css/community.css">
    <!--引入jQuery库 js样式才能生效-->
    <script src="/js/jquery-3.4.1.min.js"></script>
    <script src="/js/bootstrap.min.js" type="application/javascript"></script>
    <script src="/js/community.js" type="application/javascript"></script>
    <!--markdown js-->
    <script src="/js/editormd.min.js" type="application/javascript"></script>
</head>
<body>
<!--导航栏-->
<div th:insert="~{navigation.html :: nav}"></div>
<!--流式布局容器-->
<div class="container-fluid main">
    <div class="row">
        <!--左半部分-->
        <div class="col-lg-9 col-md-12 col-sm-12 col-sm-12">
            <h2><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 发起</h2>
            <hr>
            <form action="/publish" method="post">
                <!--name属性记得加-->
                <input type="hidden" th:value="${id}" name="id">
                <div class="form-group">
                    <label for="title">问题标题（简单扼要）:</label>
                    <input type="text" class="form-control" id="title" name="title" placeholder="问题标题..."
                           th:value="${title}" autocomplete="off">
                </div>

                <div class="form-group" id="question-editor">
                    <label for="description">问题补充 (必填，请参照右侧提示):</label>
                    <textarea name="description" id="description"
                              class="form-control"
                              cols="30"
                              rows="10" th:text="${description}" style="display:none;"></textarea>
                </div>
                <script type="text/javascript">
                    $(function () {
                        editormd("question-editor", {
                            width: "100%",
                            height: "500px",
                            path: "/js/lib/",
                            delay: 0,
                            placeholder: "请输入问题描述",
                            /*图片上传*/
                            imageUpload: true,
                            imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
                            imageUploadURL: "/file/upload"
                        });
                    });
                </script>
                <div class="form-group">
                    <label for="tag">添加标签:</label>
                    <input type="text" class="form-control" id="tag" name="tag"
                           autocomplete="off"
                           placeholder="输入标签，以，号分隔" th:value="${tag}" onclick="showSelectTag()">
                </div>


                <div id="select-tag" class="publish-tab-tag">
                    <ul class="nav nav-tabs" role="tablist">
                        <li role="presentation" th:each="tag,tagStat: ${tags}"
                            th:class="${tagStat.first ? 'active':''}">
                            <a th:href="${'#'+tag.categoryName}" aria-controls="home" role="tab" data-toggle="tab"
                               th:text="${tag.categoryName}"></a>
                        </li>
                    </ul>
                    <div class="tab-content publish-tag-padding">
                        <div role="tabpanel" class="tab-pane" th:classappend="${tagStat.first ? 'active':''}"
                             th:id="${selectCategory.categoryName}" th:each="selectCategory,tagStat:${tags}">
                            <span class="label label-info" th:each="selectTag:${selectCategory.tags}">
                                <span class="glyphicon glyphicon-tags" onclick="selectTag(this)"
                                      th:text="${' '+selectTag}" th:data-tag="${selectTag}"></span>
                            </span>
                        </div>
                    </div>

                </div>

                <span class="alert alert-danger" th:if="${error!=null}" th:text="${error}"></span>
                <!--别忘记submit提交-->
                <button type="submit" class="btn btn-success btn-publish">发布</button>
            </form>

        </div>


        <!--右半部分-->
        <div class="col-lg-3 col-md-12 col-sm-12 col-sm-12">
            <h3>问题发起指南</h3>
            • 问题标题: 请用精简的语言描述您发布的问题，不超过25字 <br>
            • 问题补充: 详细补充您的问题内容，并确保问题描述清晰直观, 并提供一些相关的资料<br>
            • 选择标签: 选择一个或者多个合适的标签，用逗号隔开，每个标签不超过10个字<br>
        </div>
    </div>
</div>
<!--页尾-->
<div th:insert="~{foot.html :: foot}"></div>
</body>
</html>